import { redirect } from "next/navigation";

import { OutputForm } from "@/components/outputs/output-form";
import { getAuthenticatedUser, getProjectSummaries } from "@/lib/server-data";

export default async function OutputCreatePage() {
  const user = await getAuthenticatedUser();

  if (!user) {
    redirect("/auth/login");
  }

  const projects = await getProjectSummaries();

  return (
    <section className="mx-auto flex w-full max-w-3xl flex-col gap-6 px-6 py-12">
      <div className="space-y-2">
        <h1 className="text-2xl font-semibold">日报上报</h1>
        <p className="text-sm text-muted-foreground">
          选择项目、填写日期与产值，将今日成果快速记录到系统中。提交后数据会立即同步到日报列表与项目详情。
        </p>
      </div>
      <div className="rounded-lg border border-border bg-card p-6 shadow-sm">
        <OutputForm projects={projects} />
      </div>
    </section>
  );
}
